import 'package:dali_ng_pera/net/dnp_net_config.dart';
import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';
import '../manager/dnp_cache_manager.dart';
import '../page/splash/dnp_splash_entity.dart';
import 'dnp_global_controller.dart';

class DnpGlobalManager {

  static final DnpGlobalManager _shareInstance = DnpGlobalManager._();
  factory DnpGlobalManager() => _shareInstance;
  DnpGlobalManager._();

  final controller = Get.find<DnpGlobalController>();

  setBuildContext(BuildContext ctx) {
    controller.context = ctx;
  }

  BuildContext? get ctx {
    return controller.context;
  }

  setSplashEntity(DnpSplashEntity splashEntity) {
    controller.splashEntity = splashEntity;
    DnpNetConfig().saveLoudness(splashEntity.loudness);
  }

  DnpSplashEntity get splashEntity {
    return controller.splashEntity;
  }

  bool get isRegister {
    return knowledge.isNotEmpty;
  }

  String get knowledge {
    String? value = DnpCacheManager().getString("KDnpKnowledge");
    return value ?? "";
  }
}